using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using FutureOpen.Core.func.clas;

namespace FutureOpen.Classifier
{
    class Program
    {       
        static void TestMethod(SVNClas svmcls, string content)
        {

            ClasCat[] result = svmcls.Test(content);
            foreach (ClasCat cat in result)
            {
                Console.WriteLine(cat.Name + "\t" + cat.Score);
            }
            Console.WriteLine("**************");
        }

        static void TestModel()
        {
            ClasList clali = new ClasList("d:\\exp\\train");
            SVNClas svmcls = new SVNClas(clali);
            //svmcls.TrainModel("F:\\data\\train");
            //svmcls.SaveModel("F:\\data\\model"); 
            svmcls.LoadModel("d:\\exp\\trainmodel");


            //BatchTest(svmcls);
            string content = File.ReadAllText("F:\\test.txt");
            TestMethod(svmcls, content);


        }

        static void TrainModel()
        {
            ClasList clali = new ClasList("d:\\exp\\train");
            SVNClas svmcls = new SVNClas(clali);

            svmcls.TrainModel("D:\\exp\\train");
            svmcls.SaveModel("D:\\exp\\trainmodel");


        }


        static void Main(string[] args)
        {
            //TrainModel();
            TestModel();
            /*
            string[] DirectoriesArray = Directory.GetDirectories("F:\\data\\test");
            Array.Sort(DirectoriesArray);
            for (int i = 0; i < DirectoriesArray.Length; i++)
            {
                DirectoryInfo p2 = new DirectoryInfo(DirectoriesArray[i]);
                FileInfo[] txtFiles = p2.GetFiles();
                foreach (FileInfo oneTxt in txtFiles)
                {
                    string test = File.ReadAllText(oneTxt.FullName, Encoding.Default);
                    ClasCat[] result = svmcls.Test(test);
                    Console.WriteLine(result[0].name);
                }
                Console.WriteLine();
            }*/

        }
    }
}
